import { Button, Form } from 'antd';
import Search from 'antd/es/input/Search';
import axios from 'axios';
import React, { useEffect,useCallback } from 'react'
import SearchForm from '../SearchForm';

/** 1.导出excel
 *  2.播放视频切片
 * 
 */

export default function Test() {
 
  const [form] = Form.useForm();
  const [count, setCount] = React.useState(0);
  const f1=useCallback(()=>{
    console.log('f1执行 count='+count);
  },[])
  useEffect(() => {
    f1();
  },[f1])
  async function exportData() {
    fetch('/home/export', {
      method: 'GET',
  })
  .then(response => {
      if (response.ok) {
          // 将响应转换为 blob
          return response.blob();
      } else {
          throw new Error('导出失败');
      }
  })
  .then(blob => {
      // 创建一个链接并触发下载
      const url = window.URL.createObjectURL(blob);
      const a = document.createElement('a');
      a.href = url;
      a.download = 'users.xlsx';
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a);
      window.URL.revokeObjectURL(url);
  })
  .catch(error => {
      console.error('导出失败:', error);
  });
   
}

  return (
    <>
    
      <Button onClick={exportData}>导出</Button>


      
    </>
   

  )
}
